package com.enums;

import com.alibaba.fastjson.JSONObject;

public enum WebSocketMessageEnum {

    /**
     * 服务发送
     */
    PAY_SUCCESS("支付成功", "PAY_SUCCESS"),
    CONNECT_SUCCESS("连接成功", "CONNECT_SUCCESS"),
    VERSION_NUMBER_UPGRADE("版本号升级", "VERSION_NUMBER_UPGRADE"),
    HEART_CHECK("心跳检测", "HEART_CHECK"),
    FRONT_PARAM_RENEW("前端配置参数更新", "FRONT_PARAM_RENEW");
    public final String describe;
    public final String value;

    WebSocketMessageEnum(String describe, String value) {
        this.describe = describe;
        this.value = value;
    }

    public String getDescribe() {
        return describe;
    }

    public String getValue() {
        return value;
    }

    public JSONObject getJsonValue() {
        return new JSONObject().fluentPut("code", value);
    }

    public static String getDescribe(String value) {
        for (WebSocketMessageEnum p : WebSocketMessageEnum.values()) {
            if (value.equals(p.getValue())) {
                return p.getDescribe();
            }
        }
        return null;
    }

}
